import requests
import re
import pprint
from pyquery import PyQuery as pq
from selenium import webdriver

headers = {'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36'} 

url = 'https://music.migu.cn/v3/music/playlist'
playlists_id =[]
playlists_name = []
html = requests.get(url,headers=headers)
html.encoding = 'utf-8'
html2list=list(html.text.split('\n'))

with open('/home/zy/Desktop/123.txt', 'w+') as f:
	f.writelines(html2list)
	f.close()
with open ('/home/zy/Desktop/123.txt', 'r+') as f:
	searchlist = str(f.readlines())
	type_id= re.findall(r'<a href="/v3/music/playlist.{1}tagId=\d{10}.*?">(.*?)</a>', searchlist)	# type_id
	type_name= re.findall(r'<a href="/v3/music/playlist.{1}tagId=(\d{10}).*?">.*?</a>', searchlist)	# name
	f.close()

playlists_id.extend(type_id)
playlists_name.extend(type_name)
playlists_tn = {}
playlists_tn = dict(zip(playlists_name,playlists_id))

# pprint.pprint(playlists_tn)


